package com.gzzz.shift;

import java.io.*;
import java.util.ArrayList;

/**
 * ClassName: CircleShift
 * Package: circleShift
 * Description:
 *
 * @Author 韩乐宇
 * @Create 2023/12/5 12:07
 * @Version 1.0
 */
public class CircleShift {
    public static ArrayList<String> shift(InputStream inputStream) {
        ArrayList<String> list = new ArrayList<String>();
        BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
        String s1;
        try {
            while ((s1=r.readLine()) != null) {
                if(s1.equals(""))continue;
                if(s1.charAt(0)==' '){
                    s1=s1.substring(1);
                }
                if(s1.charAt(s1.length()-1)==' '){
                    s1=s1.substring(0,s1.length()-1);
                }
                //list.add(s1);
                //找到空格数
                int count=0;
                boolean letterTag=true;
                for(int i=0;i<s1.length();i++){
                    char tem = s1.charAt(i);
                    if (tem == ' ') {
                        // 空格
                        count++;
                    }
                    else if(!('A'<=tem&&tem<='Z'||'a'<=tem&&tem<='z')){
                        letterTag=false;
                        break;
                    }
                }
                if(!letterTag)continue;
                String[] arr = s1.split("\\s+");
                for(int i=0;i<arr.length;i++){
                    String s2="";
                    for(int j=0;j<arr.length;j++){
                        s2+=arr[(j+i)%arr.length]+' ';
                    }
                    s2=s2.substring(0,s2.length()-1);
                    list.add(s2);
                }

            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }
        return list;
    }

//    public static void main(String[] args) {
//        ArrayList<String> strings = new ArrayList<>();
//
//    }
}
